﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Configuration;

namespace UygulamaYetkiService
{
    [Serializable]
    public class GenelDAO : IDisposable
    {
        public bool BosDegerMiKontrol(string value)
        {
            bool sonuc = false;
            try
            {
                if (value == null || value.Trim() == null || value.Trim().Length == 0 || string.IsNullOrEmpty(value.Trim()) || value.Trim() == string.Empty)
                    sonuc = false;
                else
                    sonuc = true;
            }
            catch (Exception ex)
            {
                sonuc = false;
                using (ExceptionLogDao el = new ExceptionLogDao())
                {
                    el.HataLogYaz(DateTime.Now.ToString() + "  " + ex.ToString());
                }
            }
            return sonuc;
        }

        public bool SqlInjectionControl(string text)
        {
            bool sonuc = true;
            try
            {
                foreach (var item in ConfigurationManager.AppSettings["SQLINJECTIONCHARS"].Split(','))
                {
                    if (text.ToUpper().Contains(item.ToUpper()))
                        sonuc = false;
                }
            }
            catch (Exception ex)
            {
                sonuc = false;
                using (ExceptionLogDao el = new ExceptionLogDao())
                {
                    el.HataLogYaz(DateTime.Now.ToString() + "  " + ex.ToString());
                }
            }
            return sonuc;
        }

        public void Dispose()
        {
        }
    }
}
